var p1 = new Promise((resolve,reject) => {
	setTimeout(() => {
		resolve('p1 1000');
	}, 1000)
})


var p2 = new Promise((resolve,reject) => {
	setTimeout(() => {
		// resolve('p2 2000');
		reject('p2 2000 failed');
	}, 2000)
})


var p3 = new Promise((resolve,reject) => {
	setTimeout(() => {
		resolve('p3 3000');
	}, 3000)
})


console.time('Promise.all')
Promise.all([p1, p3, p2]).then(results=> {
	console.log(results)
	console.timeEnd('Promise.all')
	console.log('----------- Promise.all ------------\n')
}, reason=> {
	console.warn(reason)
	console.timeEnd('Promise.all')
	console.log('----------- Promise.all ------------\n')
})


console.time('Promise.race')
Promise.race([p3, p2, p1, ]).then(results=> {
	console.log(results)
	console.timeEnd('Promise.race')
	console.log('----------- Promise.race ------------\n')
	
}, reason=> {
	console.warn(reason)
	console.timeEnd('Promise.race')
	console.log('----------- Promise.race ------------\n')
})